<template>
  <div>
      <h3>worker对象</h3>
      <button @click="fn">按钮</button>
  </div>
</template>

<script>
  export default {
      data(){
         return {

         }
      },
      methods:{
         fn(){
            var worker = new Worker("./worker.js")   //此时这个脚本代码也执行了
            console.log(worker);    //先打印主线程的内容再到独立线程的内容
            worker.postMessage("主线程中的内容")
            worker.onmessage = function (e) {
               console.log(e);
            }
         }
      },
      mounted(){
         
      }
  }
</script>
<style lang='less' scoped>

</style>